<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../lib/vue.js"></script>
    <style>
        .static {
            width: 200px;
            height: 200px;
            text-align: center;
            line-height: 200px;
            font-size: 24px;
            color: rgb(170, 192, 221);
            font-weight: bold;
            margin: 10px;
        }

        .a {
            border: 3px solid #333;
        }

        .b {
            background: rgb(247, 14, 45);
        }

        .c {
            border-radius: 50%;
        }

        .main {
            margin: 20px;
        }

        .nav {
            display: flex;
        }

        .nav-item {
            width: 100px;
            height: 40px;
            line-height: 40px;
            box-sizing: border-box;
            color: dodgerblue;
            background: turquoise;
            border-radius: 10px;
            font-size: 14px;
            margin: 10px;
            text-align: center;
        }

        .nav-active {
            background: lavender;
            color: #333;
        }

        .content-item {
            width: 350px;
            height: 350px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 34px;
            background: rgb(170, 192, 221);
            color: rgb(210, 224, 146);
            border-radius: 20px;
            margin: 10px;
            animation: content-item 3s reverse;

        }

        @keyframes content-item {
            0% {
                transform: scale(0);
            }

            50% {
                transform: scale(1.5);
            }

            100% {
                transform: scale(1);
            }

            0% {
                transform: scale(1);
            }

            50% {
                transform: scale(1.5);
            }

            100% {
                transform: scale(0);
            }
        }
    </style>
</head>

<body>
    <div id="app">
        <h2>{{title}}</h2>
        <div v-show="false">
            <div class="static a b c">One</div>
            <div class="static a" :class="myclass">two</div>
            <div class="static a" :class="'b'">Three</div>
            <div class="static a" :class="{b:isb,c:isc}">Four</div>
            <div class="static a" :class="[classB,classC]">Five</div>
            <div class="static a" :class="['b']">Six</div>
            <div class="static" :style="{borderRadius:'50%',background:'yellow',color:'#fff',fontSize:'30px'}">
                Seven
            </div>
            <div class="static" :style="styleObj">
                Eight
            </div>
        </div>
        <div class="main">
            <div class="nav">
                <div @click="current=0" class="nav-item" :class="current==0?'nav-active':''  ">爱情小说</div>
                <div @click="current=1" class="nav-item" :class="current==1?'nav-active':''  ">修仙小说</div>
                <div @click="current=2" class="nav-item" :class="current==2?'nav-active':''  ">都市恋情
                </div>
            </div>
            <div class="content">
                <div class="content-item " :style="{display:current==0?'flex':'none'}">
                    爱情小说 - (10)
                </div>
                <div class="content-item" :style="{display:current==1?'flex':'none'}">
                    修仙小说 - (30)
                </div>
                <div class="content-item" :style="{display:current==2?'flex':'none'}">
                    都市恋情 - (50)
                </div>
            </div>
        </div>
    </div>
</body>
<script>
    const vm = new Vue({
        data: {
            title: "动态的CSS(class && style) 切换",
            myclass: "b c",
            isb: true,
            isc: true,
            classB: "b",
            classC: "c",
            styleObj: {
                background: "pink",
                borderRadius: "10%",
                fontSize: '40px',
            },
            // a: {
            //     transition: "all .3s ease",
            //     transition: "all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0)",
            //     transform: "translateX(10px)",
            //     opacity: 0
            // },
            current: 0,
        },
        methods: {
            jishuqi() {
                setInterval(() => {
                    this.current++;
                    if (this.current == 3) {
                        this.current = 0
                    }
                }, 3500)
            }
        }

    }).$mount("#app")
    vm.jishuqi()
</script>
<!-- 

    动态的class 和style切换
    v-bind 用于 class和style时，Vue.js做了专门的增强 除了字符串之外，还可以对象或数组
    v-bind
    v-bind：class
    ：class="" {} []
    v-bind:style
    :style = {} [{}]
    :style="{}"

 -->

</html>